<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Java Service Wrapper - Integration Methods</title>
<style media="all" type="text/css">
            @import url("./style/wrapper.css");
        </style>
</head>
<body bgcolor="#eeeeff" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" alink="#023264" vlink="#023264" link="#525D76" text="#000000">
<map name="wrapperLogo">
<area href="http://wrapper.tanukisoftware.org" coords="90,90,88" shape="circle">
</map>
<map name="wrapperTitle">
<area href="http://www.tanukisoftware.com" coords="28,32,176,48" shape="rect">
</map>
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td valign="top" width="180">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td width="180"><img usemap="#wrapperLogo" border="0" height="180" width="180" src="images/WrapperLogo.png"></td>
</tr>
<tr>
<td>
<table cellpadding="4" cellspacing="0" width="100%" border="0">
<tr>
<td nowrap="true">
<div id="menu">
<script language="JavaScript">//@@MENU_TOP@@</script>
<div>
<b>Essentials</b>
<div>
<a href="introduction.html">Introduction</a>
</div>
<div>
<a href="integrate.html">Integration Methods</a>
</div>
<div>
<a href="properties.html">Configuration Properties</a>
</div>
<div>
<a href="launch.html">Launching Your Application</a>
</div>
<div>
<b>
                        &gt;&gt;
                        <a href="donate.html">Show Your Support</a>
                        &lt;&lt;
                    </b>
</div>
<div>
<a href="sponsors.html">Sponsors</a>
</div>
</div>
<div>
<b>Documentation</b>
<div>
<a href="jmx.html">JMX Control</a>
</div>
<div>
<a href="security-model.html">Security Model</a>
</div>
<div>
<a href="example.html">Feature Examples</a>
</div>
<div>
<a href="debugging.html">Debugging Your Application</a>
</div>
<div>
<a href="troubleshooting.html">Troubleshooting</a>
</div>
<div>
<a href="faq.html">FAQ</a>
</div>
<div>
<a href="release-notes.html">Release Notes</a>
</div>
<div>
<a href="history.html">Project History</a>
</div>
<div>
<a href="javadocs.html">Javadocs API</a>
</div>
<div>
<a href="buttons.html">Buttons</a>
</div>
<div>
<a href="authors.html">Authors</a>
</div>
<div>
<a href="license.html">License</a>
</div>
</div>
<div>
<b>Download</b>
<div>
<a href="http://sourceforge.net/project/showfiles.php?group_id=39428&package_id=31591">Binaries</a>
</div>
<div>
<a href="http://sourceforge.net/project/showfiles.php?group_id=39428&package_id=33658">Source Code</a>
</div>
</div>
<div>
<b>Get Involved</b>
<div>
<a href="http://sourceforge.net/projects/wrapper/">Source Forge</a>
</div>
<div>
<a href="http://svn.sourceforge.net/viewvc/wrapper/">Subversion Repository</a>
</div>
<div>
<a href="http://sourceforge.net/tracker/?group_id=39428">Issue Tracking</a>
</div>
<div>
<a href="http://sourceforge.net/mail/?group_id=39428">Mailing Lists and Archives</a>
</div>
<div>
<a href="http://sourceforge.net/forum/?group_id=39428">Forums (Old)</a>
</div>
</div>
</div>
<script language="JavaScript">//@@MENU_BOTTOM@@</script>
<p>
<b>Hosted by:</b>
<br>
<a href="http://sourceforge.net/projects/wrapper/"><img alt="SourceForge" border="0" height="31" width="88" src="http://sourceforge.net/sflogo.php?group_id=39428"></a>
<br>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td><td valign="top" width="*">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td colspan="3"><img height="4" src="images/spacer.gif"></td>
</tr>
<tr>
<td align="center" height="90" colspan="2"><a href="http://wrapper.tanukisoftware.org"><img border="0" height="90" width="728" src="images/OfflineAd728x90.png"></a></td><td rowspan="5"><img width="4" src="images/spacer.gif"></td>
</tr>
<tr>
<td height="49" width="435"><img usemap="#wrapperTitle" border="0" height="49" width="435" src="images/WrapperTitle.png"></td><td valign="bottom" align="right" width="*"><a href="donate.html"><img border="0" height="16" width="300" src="images/DonationRequest.png"></a></td>
</tr>
<tr>
<td height="4" colspan="2"><img height="4" width="500" src="images/BorderTop.png"></td>
</tr>
<tr>
<td colspan="2">
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td valign="top" width="4"><img height="496" width="4" src="images/BorderLeft.png"></td><td bgcolor="#ffffff" valign="top" width="*" colspan="2">
<table cellpadding="4" cellspacing="0" width="100%" border="0">
<tr>
<td nowrap="true" align="center"><font zcolor="#115b77" color="#8888aa" size="5"><b>Integration Methods</b></font></td>
</tr>
<tr>
<td>
<title>Integration Methods</title>
    
    
<a name="N10009"></a>
<table cellpadding="2" cellspacing="0" width="100%" border="0">
<tr>
<td bgcolor="#8888aa" class="sectionheader1" width="*"><font color="#eeeeee" size="4"><b>Methods of Integrating with the Java Service Wrapper</b></font></td>
</tr>
<tr>
<td><img height="4" width="1" src="./images/spacer.gif"></td>
</tr>
<tr>
<td>
        
        
<p>
            There are currently three ways which an application can integrate with
            the Java Service Wrapper.  Two of which will work out of the box
            without any additional coding.  The first step is to decide which of
            these three methods is best for your application.  After a brief
            overview of each of the three options, we will go into detail how
            to integrate an application using each.
        </p>
        
<a name="method1"></a>
<table cellpadding="2" cellspacing="0" width="100%" border="0">
<tr>
<td rowspan="3" width="10"><img height="1" width="10" src="./images/spacer.gif"></td><td bgcolor="#9999bb" class="sectionheader2" width="*"><font color="#eeeeee" size="3"><b>Method 1</b></font></td>
</tr>
<tr>
<td><img height="4" width="1" src="./images/spacer.gif"></td>
</tr>
<tr>
<td>
            
            
<p>
                The first method is to use the
                <tt>WrapperSimpleApp</tt> helper class to
                launch the application.  This is by far the simplest way to integrate
                with the Wrapper, and where possible, it is highly recommended.  There
                are some things to be aware of when using this method however.  When
                the Wrapper shuts down the JVM, there is no direct call to an
                application requesting that it shutdown cleanly.  Rather, the Wrapper
                will exit the JVM by calling <tt>System.exit()</tt>
                from within the JVM.  If the application has registered its own shutdown
                hook, it will be invoked, giving the application a chance to shutdown
                cleanly.  If on the other hand, a shutdown hook is not registered, then
                the application will suddenly exit.   Both cases, with and without a
                shutdown hook, provide the exact same behavior as if the application
                was running without the Wrapper and a user pressed CTRL-C in the console.
            </p>
            
<p>
                Detailed overview and instructions, using
                <a href="http://www.jboss.org">JBoss</a> as an example.
                (<a href="integrate-simple-win.html">Win32</a>
                or <a href="integrate-simple-nix.html">Linux / UNIX</a>).
            </p>
        
</td>
</tr>
</table>
        
<a name="method2"></a>
<table cellpadding="2" cellspacing="0" width="100%" border="0">
<tr>
<td rowspan="3" width="10"><img height="1" width="10" src="./images/spacer.gif"></td><td bgcolor="#9999bb" class="sectionheader2" width="*"><font color="#eeeeee" size="3"><b>Method 2</b></font></td>
</tr>
<tr>
<td><img height="4" width="1" src="./images/spacer.gif"></td>
</tr>
<tr>
<td>
            
            
<p>
                The second method is to use the
                <tt>WrapperStartStopApp</tt> helper class.
                This method provides a way to integrate with applications like Tomcat,
                which are started using one class and then stopped using another
                class.  Typically, this kind of application will open a server socket
                on startup whose job is to wait for a connection which triggers a
                shutdown.  The shutdown, or "stop", class when launched then triggers
                the shutdown by connecting to application.   The Wrapper works with
                this kind of application by starting up the application, as in the
                first method, using the "start" class and then calling the main method
                of the "stop" class when it is time for the application to be shutdown.
            </p>
            
<p>
                Detailed overview and instructions, using
                <a href="http://tomcat.apache.org/">Tomcat</a> as an
                example.  (<a href="integrate-start-stop-win.html">Win32</a>
                or <a href="integrate-start-stop-nix.html">Linux / UNIX</a>).
            </p>
        
</td>
</tr>
</table>
        
<a name="method3"></a>
<table cellpadding="2" cellspacing="0" width="100%" border="0">
<tr>
<td rowspan="3" width="10"><img height="1" width="10" src="./images/spacer.gif"></td><td bgcolor="#9999bb" class="sectionheader2" width="*"><font color="#eeeeee" size="3"><b>Method 3</b></font></td>
</tr>
<tr>
<td><img height="4" width="1" src="./images/spacer.gif"></td>
</tr>
<tr>
<td>
            
            
<p>
                The third and final method, while providing the most flexibility and
                access to all of the Wrapper's features, is also the only one which
                requires some coding to complete the integration.  This method
                involves creating a class which implements the
                <tt>WrapperListener</tt> interface.
                An instance of the user class is then instantiated and registered with
                the <tt>WrapperManager</tt>.
            </p>
            
<p>
                While this method provides features that are not available with
                either of the first two methods, it does add some complexity.
                If the additional features are not required, implementing a
                shutdown hook to enable the use of <a href="#method1">Method 1</a>,
                or implementing a shutdown class should be considered as options.
                The main method of a shutdown class can be as simple as just calling a
                shutdown method in the application.
            </p>
            
<p>
                This is the only method which allows user code to receive and respond
                directly to system control events as well as the startup and shutdown
                process.   In most cases this added control is not necessary however,
                as both the
                <tt><a href="#method1">WrapperSimpleApp</a></tt>
                and
                <tt><a href="#method2">WrapperStartStopApp</a></tt>
                helper classes take care of this for you by starting up and shutting
                down the application at the appropriate times.
            </p>
            
<p>
                Detailed overview and instructions
                (<a href="integrate-listener.html">Platform Independent</a>).
            </p>
        
</td>
</tr>
</table>
        
<div class="note">
<table cellspacing="0" cellpadding="2" width="100%" border="0">
<tr>
<td nowrap="nowrap" valign="top">
<p class="notelabel">
<font color="#0000a0"><b>NOTE MEG</b></font>
</p>
</td><td><img width="10" src="images/spacer.gif"></td><td bgcolor="#bbbbdd" class="notebody"><font color="#222260">
            
<p>
                The Wrapper can be used with 1.2.x versions however some functions are disabled
                due to this version of Java's lack of support for shutdown hooks.  Shutdown
                hooks were implemented with the 1.3.0 release of Java.
            </p>
            
<p>
                Integration <a href="#method1">method #1</a> can be used, but the
                application will not be shutdown cleanly.  This method normally relies
                on an application's own shutdown hook to handle any work that needs to
                be done before the JVM shuts down.  To guarantee a clean shutdown of the
                application, <a href="#method2">Methods #2</a> or
                <a href="#method3">#3</a>, which both directly allow code to be
                executed on shutdown must be used.
            </p>
        
</font></td>
</tr>
</table>
</div>
    
</td>
</tr>
</table>

</td>
</tr>
<tr>
<td align="right" id="author">
<p>
<i>by Leif Mortenson</i>
</p>
</td>
</tr>
</table>
<script language="JavaScript">//@@BODY_SECTION@@</script></td><td valign="bottom" width="4"><img height="496" width="4" src="images/BorderRight.png"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" height="4" colspan="2"><img height="4" width="500" src="images/BorderBottom.png"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellpadding="2" cellspacing="0" border="0" width="100%">
<tr>
<td id="copyright" align="left"><font color="#525D76" size="-1" face="arial,helvetica,sanserif"><i>
                            Copyright &copy;1999-2004 by <a href="http://www.tanukisoftware.com">Tanuki Software</a>.
                            All Rights Reserved.
                        </i></font></td><td align="right"><font color="#525D76" size="-1" face="arial,helvetica,sanserif"><i>
                            last modified:
                            <script language="JavaScript"> document.write(document.lastModified); </script></i></font></td>
</tr>
</table>
</body>
</html>
